home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / cxl52_1.zip / CXLWIN.H < prev    next >
C/C++ Source or Header  |  1990-02-17  |  23KB  |  463 lines

  1. /*
  2.    ┌──────────────────────────────────────────────────────────────────────────┐
  3.    │                                                                          │
  4.    │  CXLWIN.H  -  CXL is Copyright (c) 1987-1990 by Mike Smedley.            │
  5.    │                                                                          │
  6.    │  This header file contains function prototypes and definitions for       │
  7.    │  windowing functions.                                                    │
  8.    │                                                                          │
  9.    └──────────────────────────────────────────────────────────────────────────┘
  10. */
  11.  
  12. #if defined(__TURBOC__)                     /* Turbo C */
  13.     #if __STDC__
  14.         #define _Cdecl
  15.     #else
  16.         #define _Cdecl  cdecl
  17.     #endif
  18.     #define _Near
  19. #elif defined(__ZTC__)                      /* Zortech C++ */
  20.     #define _Cdecl
  21.     #define _Near
  22. #elif defined(M_I86) && !defined(__ZTC__)   /* Microsoft C/QuickC */
  23.     #if !defined(NO_EXT_KEYS)
  24.         #define _Cdecl  cdecl
  25.         #define _Near   near
  26.     #else
  27.         #define _Cdecl
  28.         #define _Near
  29.     #endif
  30. #endif
  31.  
  32.  
  33. /*------------------------------[ WINDOW type ]------------------------------*/
  34.  
  35. typedef int     WINDOW;
  36.  
  37. /*---------------------------[ function prototypes ]-------------------------*/
  38.  
  39. int      _Cdecl wactiv(WINDOW whandle);
  40. int      _Cdecl wborder(int btype);
  41. int      _Cdecl wbox(int wsrow,int wscol,int werow,int wecol,int btype
  42.                 ,int attr);
  43. int      _Cdecl wbprintc(int bord,int offs,int attr,int ch);
  44. int      _Cdecl wcclear(int attr);
  45. int      _Cdecl wcenters(int wrow,int attr,char *str);
  46. int      _Cdecl wchgattr(int battr,int wattr);
  47. int      _Cdecl wchkbox(int wsrow,int wscol,int werow,int wecol);
  48. int      _Cdecl wchkcol(int wcol);
  49. int      _Cdecl wchkcoord(int wrow,int wcol);
  50. int      _Cdecl wchkrow(int wrow);
  51. int      _Cdecl wclose(void);
  52. int      _Cdecl wcloseall(void);
  53. int      _Cdecl wclreol(void);
  54. int      _Cdecl wclreos(void);
  55. WINDOW   _Cdecl wcopy(int nsrow,int nscol);
  56. int      _Cdecl wdelline(int wrow,int direc);
  57. int      _Cdecl wdrag(int direction);
  58. int      _Cdecl wdump(void);
  59. int      _Cdecl wdupc(int ch,int count);
  60. int      _Cdecl wdups(char *str,int count);
  61. char    *_Cdecl werrmsg(void);
  62. int      _Cdecl wfill(int wsrow,int wscol,int werow,int wecol,int ch,int attr);
  63. struct   _wrec_t *_Cdecl wfindrec(WINDOW whandle);
  64. int      _Cdecl wgetc(void);
  65. int      _Cdecl wgetchf(char *valid,int defchar);
  66. int      _Cdecl wgetns(char *str,int maxchars);
  67. int      _Cdecl wgets(char *str);
  68. int      _Cdecl wgetyn(int cdefault);
  69. int      _Cdecl wgotoxy(int wrow,int wcol);
  70. WINDOW   _Cdecl whandle(void);
  71. int      _Cdecl whelpcat(int cat);
  72. int      _Cdecl whelpclr(void);
  73. int      _Cdecl whelpdef(char *file,unsigned key,int winattr,int textattr,
  74.                          int selattr,int barattr,void (_Cdecl *open)(void));
  75. int      _Cdecl whelpop(void);
  76. int      _Cdecl whelpopc(void);
  77. int      _Cdecl whelppcat(int cat);
  78. int      _Cdecl whelpush(void);
  79. int      _Cdecl whelpushc(int cat);
  80. int      _Cdecl whelpwin(int srow,int scol,int erow,int ecol,int btype,
  81.                          int title);
  82. int      _Cdecl whide(void);
  83. int      _Cdecl whline(int wsrow,int wscol,int count,int btype,int attr);
  84. WINDOW   _Cdecl windowat(int row,int col);
  85. int      _Cdecl winpbeg(int fieldattr,int textattr);
  86. int      _Cdecl winpdef(int wrow,int wcol,char *str,char *format,int fconv,
  87.                         int mode,int (_Cdecl *validate) (char *),int help);
  88. int      _Cdecl winpfba(void (_Cdecl *before)(void),
  89.                         void (_Cdecl *after)(void));
  90. struct _field_t *_Cdecl winpffind(int wrow,int wcol);
  91. int      _Cdecl winpkey(unsigned (_Cdecl *getkey)(int *),unsigned *termkey);
  92. int      _Cdecl winpread(void);
  93. int      _Cdecl winputsf(char *str,char *fmt);
  94. int      _Cdecl winsline(int wrow,int direc);
  95. int      _Cdecl wmenubeg(int srow,int scol,int erow,int ecol,int btype,
  96.                          int battr,int wattr,void (_Cdecl *open)(void));
  97. int      _Cdecl wmenubegc(void);
  98. int      _Cdecl wmenuend(int taginit,int menutype,int barwidth,int textpos,
  99.                          int textattr,int scharattr,int noselattr,int barattr);
  100. int      _Cdecl wmenuget(void);
  101. int      _Cdecl wmenuiba(void (_Cdecl *before)(void),
  102.                          void (_Cdecl *after)(void));
  103. int      _Cdecl wmenuidsab(int tagid);
  104. int      _Cdecl wmenuienab(int tagid);
  105. struct   _item_t *_Cdecl wmenuifind(int tagid);
  106. int      _Cdecl wmenuinext(int tagid);
  107. int      _Cdecl wmenuitem(int wrow,int wcol,char *str,int schar,int tagid,
  108.                           int fmask,void (_Cdecl *select)(void),
  109.                           unsigned hotkey,int help);
  110. int      _Cdecl wmenuitxt(int wrow,int wcol,int attr,char *str);
  111. int      _Cdecl wmessage(char *str,int border,int leftofs,int attr);
  112. int      _Cdecl wmove(int nsrow,int nscol);
  113. WINDOW   _Cdecl wopen(int srow,int scol,int erow,int ecol,int btype,int battr,
  114.                       int wattr);
  115. int      _Cdecl wperror(char *message);
  116. int      _Cdecl wpgotoxy(int wrow,int wcol);
  117. char    *_Cdecl wpickfile(int srow,int scol,int erow,int ecol,int btype,
  118.                           int bordattr,int winattr,int barattr,int title,
  119.                           char *filespec,void (_Cdecl *open)(void));
  120. int      _Cdecl wpickstr(int srow,int scol,int erow,int ecol,int btype,
  121.                          int bordattr,int winattr,int barattr,char *strarr[],
  122.                          int initelem,void (_Cdecl *open)(void));
  123. int      _Cdecl wprintc(int wrow,int wcol,int attr,int ch);
  124. int      _Cdecl wprintf(const char *format,...);
  125. int      _Cdecl wprints(int wrow,int wcol,int attr,char *str);
  126. int      _Cdecl wprintsf(int wrow,int wcol,int attr,char *format,char *str);
  127. int      _Cdecl wputc(int ch);
  128. int      _Cdecl wputns(char *str,int width);
  129. int      _Cdecl wputs(char *str);
  130. int      _Cdecl wputsw(char *str);
  131. int      _Cdecl wreadcur(int *wrow,int *wcol);
  132. void     _Cdecl wrestore(int *wbuf);
  133. int      _Cdecl wrjusts(int wrow,int wjcol,int attr,char *str);
  134. int     *_Cdecl wsave(int srow,int scol,int erow,int ecol);
  135. int      _Cdecl wscanf(const char *format,...);
  136. int      _Cdecl wscroll(int count,int direc);
  137. int      _Cdecl wscrollbox(int wsrow,int wscol,int werow,int wecol,int count,
  138.                            int direction);
  139. int      _Cdecl wselstr(int wrow,int wcol,int attr,char *strarr[],
  140.                         int initelem);
  141. int      _Cdecl wshadoff(void);
  142. int      _Cdecl wshadow(int attr);
  143. int      _Cdecl wsize(int nerow,int necol);
  144. int      _Cdecl wslide(int nsrow,int nscol);
  145. int      _Cdecl wtextattr(int attr);
  146. int      _Cdecl wtitle(char *str,int tpos,int tattr);
  147. int      _Cdecl wunhide(WINDOW whandle);
  148. int      _Cdecl wunlink(WINDOW w);
  149. int      _Cdecl wvline(int wsrow,int wscol,int count,int btype,int attr);
  150. int      _Cdecl wwprints(WINDOW whandle,int wrow,int wcol,int attr,char *str);
  151.  
  152. /*-------------[ error codes returned from windowing functions ]-------------*/
  153.  
  154. #define W_NOERROR   0       /* no error                          */
  155. #define W_ESCPRESS  1       /* Escape key was pressed            */
  156. #define W_ALLOCERR  2       /* memory allocation error           */
  157. #define W_NOTFOUND  3       /* record not found                  */
  158. #define W_NOACTIVE  4       /* no active window                  */
  159. #define W_INVCOORD  5       /* invalid coordinates               */
  160. #define W_INVFORMT  6       /* invalid format string             */
  161. #define W_NOINPDEF  7       /* no input fields defined           */
  162. #define W_STRLONG   8       /* string too long for window        */
  163. #define W_INVBTYPE  9       /* invalid box type                  */
  164. #define W_NOBORDER  10      /* no window border                  */
  165. #define W_NOHIDDEN  11      /* no hidden windows                 */
  166. #define W_NOTHIDD   12      /* window is not hidden              */
  167. #define W_NOSELECT  13      /* no selectable menu items          */
  168. #define W_NOITMDEF  14      /* no menu items defined             */
  169. #define W_NOMNUEND  15      /* no end of menu specified          */
  170. #define W_NOMNUDEF  16      /* no menu defined                   */
  171. #define W_NOMNUBEG  17      /* no begin of menu specified        */
  172. #define W_NOFRMDEF  18      /* no form defined                   */
  173. #define W_NOFRMBEG  19      /* no begin of form specified        */
  174. #define W_NOHLPDEF  20      /* no help record defined            */
  175. #define W_HLPSTKOV  21      /* help stack overflow               */
  176. #define W_HLPSTKUN  22      /* help stack underflow              */
  177. #define W_DOSERROR  23      /* DOS error                         */
  178. #define W_NOMATCH   24      /* no files matched input filespec   */
  179. #define W_INVTAGID  25      /* invalid tag identifier            */
  180.                                            
  181. /*-----------------------[ window border identifiers ]----------------------*/
  182.  
  183. #define TP_BORD  0      /* top border    */
  184. #define BT_BORD  1      /* bottom border */
  185. #define LT_BORD  2      /* left border   */
  186. #define RT_BORD  3      /* right border  */
  187.  
  188. /*--------------------------[ direction codes ]------------------------------*/
  189.  
  190. #define D_DOWN    0
  191. #define D_UP      1
  192. #define D_LEFT    2
  193. #define D_RIGHT   3
  194. #define SDOWN     D_DOWN    /* scroll down */
  195. #define SUP       D_UP      /* scroll up   */
  196.  
  197. /*----------------------[ menu item record definition ]----------------------*/
  198.  
  199. struct _item_t {
  200.     struct _item_t *prev;   /* pointer to previous record      */
  201.     struct _item_t *next;   /* pointer to next record          */
  202.     void *child;            /* pointer to submenu's record     */
  203.     char *str;              /* address of selection string     */
  204.     char *desc;             /* text description of menu option */
  205.     void (*select) (void);  /* address of selection function   */
  206.     void (*before) (void);  /* address of "before" function    */
  207.     void (*after)  (void);  /* address of "after"  function    */
  208.     unsigned hotkey;        /* hot key to select function      */
  209.     int tagid;              /* tag identifier                  */
  210.     int help;               /* help category number            */
  211.     int wrow;               /* start of text - window row      */
  212.     unsigned char wcol;     /* start of text - window column   */
  213.     unsigned char schar;    /* quick selection character       */
  214.     unsigned char fmask;    /* special feature mask            */
  215.     unsigned char dwrow;    /* description window row          */
  216.     unsigned char dwcol;    /* description window column       */
  217.     unsigned char dattr;    /* description attribute           */
  218.     unsigned char redisp;   /* redisplay flag                  */
  219. };
  220.  
  221. /*--------------------[ window menu record definition ]----------------------*/
  222.  
  223. struct _menu_t {
  224.     struct _menu_t *prev;       /* pointer to prev menu structure   */
  225.     struct _menu_t *next;       /* pointer to next menu structure   */
  226.     struct _menu_t *parent;     /* pointer to parent menu           */
  227.     struct _item_t *item;       /* pointer to head menu item        */
  228.     struct _item_t *citem;      /* pointer to current menu item     */
  229.     void (*open) (void);        /* address of post-opening function */
  230.     int tagcurr;                /* tag ID of item selection bar on  */
  231.     unsigned char usecurr;      /* will menu use current window?    */
  232.     unsigned char srow;         /* starting row of menu window      */
  233.     unsigned char scol;         /* starting column of menu window   */
  234.     unsigned char erow;         /* ending row of menu window        */
  235.     unsigned char ecol;         /* ending column of menu window     */
  236.     unsigned char btype;        /* menu window border type          */
  237.     unsigned char battr;        /* menu window border attribute     */
  238.     unsigned char wattr;        /* menu window attribute            */
  239.     unsigned char menutype;     /* menu type mask                   */
  240.     unsigned char barwidth;     /* width of menu bar or zero        */
  241.     unsigned char textpos;      /* offset of text from start of bar */
  242.     unsigned char textattr;     /* attribute of menu text           */
  243.     unsigned char scharattr;    /* attribute of selection character */
  244.     unsigned char noselattr;    /* non-selectable text attribute    */
  245.     unsigned char barattr;      /* attribute of selection bar       */
  246. };
  247.  
  248. /*--------------------[ window help information record ]---------------------*/
  249.  
  250. struct _help_t {
  251.     int help[20];               /* help stack                 */
  252.     char *file;                 /* help file name             */
  253.     int helpptr;                /* help stack pointer         */
  254.     unsigned int  key;          /* help hot key               */
  255.     unsigned char winattr;      /* help window attribute      */
  256.     unsigned char textattr;     /* help window text attribute */
  257.     unsigned char selattr;      /* selection text attribute   */
  258.     unsigned char barattr;      /* selection bar attribute    */
  259.     unsigned char srow;         /* help window start row      */
  260.     unsigned char scol;         /* help window start column   */
  261.     unsigned char erow;         /* help window end row        */
  262.     unsigned char ecol;         /* help window end column     */
  263.     unsigned char btype;        /* help window box type       */
  264.     unsigned char title;        /* display "Help" title?      */
  265.     void (*open) (void);        /* pointer to open function   */
  266. };
  267.  
  268. /*-----------------------[ window information record ]-----------------------*/
  269.  
  270. struct _winfo_t {
  271.     struct _wrec_t  *active;    /* pointer to active window         */
  272.     struct _wrec_t  *hidden;    /* pointer to head hidden window    */
  273.     struct _menu_t  *menu;      /* pointer to head menu record      */
  274.     struct _menu_t  *cmenu;     /* pointer to current menu record   */
  275.     struct _help_t  *helptr;    /* pointer to help info record      */
  276.     WINDOW handle;              /* last handle given to a window    */
  277.     int maxfiles;               /* max files allowed in wpickfile() */
  278.     int help;                   /* current help category            */
  279.     int errno;                  /* error num from last window func  */
  280.     int total;                  /* total number of open windows     */
  281.     int mlevel,ilevel;          /* system variables used in menus   */
  282.     unsigned char esc;          /* check for Esc in input funcions? */
  283.     unsigned char tabwidth;     /* window TTY output tab width      */
  284.     unsigned char fillch;       /* character to fill windows with   */
  285. };
  286.  
  287. extern struct _winfo_t _Near _Cdecl _winfo;
  288.  
  289. /*-------------------[ fmask definitions for wmenuitem() ]-------------------*/
  290.  
  291. #define M_HASPD     1   /* has pull-down menu attached   */
  292. #define M_NOSEL     2   /* is not selectable             */
  293. #define M_CLOSE     4   /* close menu after select func  */
  294. #define M_CLALL     8   /* close all menus when selected */
  295. #define M_CLOSB    16   /* close menu before select func */
  296.  
  297. /*------------------[ menutype definitions for wmenuend() ]------------------*/
  298.  
  299. #define M_HORZ      1       /* horizontal menu         */
  300. #define M_VERT      2       /* vertical menu           */
  301. #define M_OMNI      7       /* omnidirectional menu    */
  302. #define M_PD        8       /* pull-down menu          */
  303. #define M_NOQS      16      /* disable quick selection */
  304. #define M_SAVE      32      /* save last bar position  */
  305.  
  306. /*------------------[ special return codes from wmenuget() ]-----------------*/
  307.  
  308. #define M_EXIT      32764   /* exit menu               */
  309. #define M_EXITALL   32765   /* exit all menus          */
  310. #define M_PREVPD    32766   /* previous pull-down menu */
  311. #define M_NEXTPD    32767   /* next pull-down menu     */
  312.  
  313. /*---------------------[ window input field definition ]---------------------*/
  314.  
  315. struct _field_t {
  316.     struct _field_t *prev;      /* pointer to previous field       */
  317.     struct _field_t *next;      /* pointer to next field           */
  318.     char *str;                  /* address of receiving string     */
  319.     char *buf;                  /* address of temp receive string  */
  320.     char *format;               /* input field format string       */
  321.     int (*validate) (char *);   /* address of validation function  */
  322.     void (*before) (void);      /* address of "before" function    */
  323.     void (*after)  (void);      /* address of "after"  function    */
  324.     int help;                   /* help category number            */
  325.     int lenbuf;                 /* length of buffer                */
  326.     int lenfld;                 /* length of screen input field    */
  327.     int lenfmt;                 /* length of format string         */
  328.     unsigned char wrow;         /* start of input - window row     */
  329.     unsigned char wcol;         /* start of input - window column  */
  330.     unsigned char mode;         /* 0=init, 1=update, 2=cond update */
  331.     unsigned char decpos;       /* decimal position (numeric)      */
  332.     unsigned char redisp;       /* redisplay flag                  */
  333.     char fconv;                 /* field conversion character      */
  334. };
  335.                                  
  336. /*-------------------[ window data entry form definition ]-------------------*/
  337.  
  338. struct _form_t {
  339.     unsigned (*getkey) (int *); /* pointer to alternate get func   */
  340.     struct _form_t  *prev;      /* pointer to previous form record */
  341.     struct _form_t  *next;      /* pointer to next form record     */
  342.     struct _field_t *field;     /* pointer to head field record    */
  343.     struct _field_t *cfield;    /* pointer to current field record */
  344.     unsigned *termkey;          /* addr of int for terminating key */
  345.     char *pformat;              /* format string pointer           */
  346.     char *pbuf;                 /* buffer string pointer           */
  347.     unsigned char cwrow;        /* current window row              */
  348.     unsigned char cwcol;        /* current window column           */
  349.     unsigned char decimal;      /* decimal field flag              */
  350.     unsigned char insert;       /* insert mode flag                */
  351.     unsigned char fieldattr;    /* field attribute                 */
  352.     unsigned char textattr;     /* text attribute                  */
  353. };
  354.  
  355. /*----------------------[ structure of window records ]----------------------*/
  356.  
  357. struct _wrec_t {
  358.     struct _wrec_t *prev;   /* pointer to previous window record */
  359.     struct _wrec_t *next;   /* pointer to next window record     */
  360.     struct _form_t *form;   /* pointer to head form record       */
  361.     int *wbuf;              /* address of window's buffer        */
  362.     int *wsbuf;             /* address of window shadow's buffer */
  363.     char *title;            /* address of window's title string  */
  364.     WINDOW whandle;         /* window's handle                   */
  365.     int help;               /* help category number              */
  366.     unsigned char srow;     /* start row of window               */
  367.     unsigned char scol;     /* start column of window            */
  368.     unsigned char erow;     /* end row of window                 */
  369.     unsigned char ecol;     /* end column of window              */
  370.     unsigned char btype;    /* window's box type                 */
  371.     unsigned char wattr;    /* window's initial text attribute   */
  372.     unsigned char battr;    /* atrribute of window's border      */
  373.     unsigned char border;   /* has border?  0 = no, 1 = yes      */
  374.     unsigned char row;      /* window's current cursor row       */
  375.     unsigned char column;   /* window's current cursor column    */
  376.     unsigned char attr;     /* window's current text attribute   */
  377.     unsigned char tpos;     /* position of window's title        */
  378.     unsigned char tattr;    /* attribute of window's title       */
  379.     unsigned char wsattr;   /* attribute of window's shadow      */
  380. };                                 
  381.  
  382. /*------------[ window title position definitions for wtitle() ]-------------*/
  383.  
  384. #define TLEFT       1   /* left justified  */
  385. #define TCENTER     2   /* centered        */
  386. #define TRIGHT      3   /* right justified */
  387.  
  388. /*------------------------[ definition of NULL ]-----------------------------*/
  389.  
  390. #if !defined(NULL)
  391.     #if defined(__TURBOC__)                     /* Turbo C */
  392.         #if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  393.             #define NULL    0
  394.         #else
  395.             #define NULL    0L
  396.         #endif
  397.     #elif defined(__ZTC__)                      /* Zortech C++ */
  398.         #ifdef LPTR
  399.             #define NULL    0L
  400.         #else
  401.             #define NULL    0
  402.         #endif
  403.     #elif defined(M_I86) && !defined(__ZTC__)   /* Microsoft C/QuickC */
  404.         #if defined(M_I86SM) || defined(M_I86MM)
  405.             #define NULL    0
  406.         #else
  407.             #define NULL    0L
  408.         #endif
  409.     #endif
  410. #endif
  411.  
  412. /*--------------[ attribute codes for functions that use them ]--------------*/
  413.  
  414. #if     !defined(BLACK)     /* foreground colors */
  415. #define BLACK       0                   
  416. #define BLUE        1
  417. #define GREEN       2
  418. #define CYAN        3
  419. #define RED         4
  420. #define MAGENTA     5
  421. #define BROWN       6
  422. #define YELLOW      14
  423. #define WHITE       15
  424. #endif
  425. #if     !defined(LGREY)
  426. #define LGREY       7       /* CXL abbreviates LIGHT as L    */
  427. #define DGREY       8       /* and DARK as D for ease of use */
  428. #define LBLUE       9
  429. #define LGREEN      10
  430. #define LCYAN       11
  431. #define LRED        12
  432. #define LMAGENTA    13
  433.  
  434. #define _BLACK      0       /* background colors */
  435. #define _BLUE       16
  436. #define _GREEN      32
  437. #define _CYAN       48
  438. #define _RED        64
  439. #define _MAGENTA    80
  440. #define _BROWN      96
  441. #define _LGREY      112
  442. #endif
  443.  
  444. #if     !defined(BLINK)
  445. #define BLINK       128     /* blink attribute */
  446. #endif
  447.  
  448. /*----------------------------[ macro functions ]----------------------------*/
  449.  
  450. #if !defined(MK_FP)
  451. #define MK_FP(seg,ofs)      ((void far *) (((unsigned long)(seg) << 16) | \
  452.                             (unsigned)(ofs)))
  453. #endif
  454. #define wclear()            wcclear(_winfo.active->wattr)
  455. #define wfillch(a)          (_winfo.fillch=a)
  456. #define whelpundef()        whelpdef(NULL,0,0,0,0,0,NULL)
  457. #define winpfcurr()         (_winfo.active->form->cfield)
  458. #define wisactiv(a)         (a==_winfo.active->whandle)
  459. #define wmenumcurr()        (_winfo.cmenu)
  460. #define wmenuicurr()        (wmenumcurr()->citem)
  461. #define wsetesc(a)          (_winfo.esc=a)
  462. #define wtabwidth(a)        (_winfo.tabwidth=((a==0)?1:a))
  463.